package com.qingcloud.adminbackend.mapper;

import com.qingcloud.adminbackend.entity.sysstation.SysStationEquipment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qingcloud.adminbackend.entity.stationequipment.OptStationEquipment;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 监测点设备绑定记录表 Mapper 接口
 * </p>
 *
 * @author liyuhong
 * @since 2019-01-02
 */
public interface SysStationEquipmentMapper extends BaseMapper<SysStationEquipment> {
    /**
     * 设备绑定监测点
     *
     * @param sysStationEquipments
     */
    void insertStationEquipments(@Param("sysStationEquipments") List<SysStationEquipment> sysStationEquipments);

    /**
     * 批量解除设备与检测的绑定关系
     *
     * @param sysStationEquipments
     */
    void deleteStationEquipments(@Param("sysStationEquipments") List<SysStationEquipment> sysStationEquipments);

    /**
     * 验证设备与检测的绑定关系
     *
     * @param sysStationEquipments
     * @return
     */
    List<SysStationEquipment> findStationEquipments(@Param("sysStationEquipments") List<SysStationEquipment> sysStationEquipments);

    /**
     * 解绑设备
     *
     * @param optStationEquipment
     */
    void unbind(OptStationEquipment optStationEquipment);

    /**
     * 绑定设备
     *
     * @param optStationEquipment
     */
    void bind(OptStationEquipment optStationEquipment);

    /**
     * 根据检测点ID查询检测点绑定状态
     *
     * @param stationId
     * @return
     */
    Integer findBandStatusByStationId(@Param("stationId") String stationId);

    /**
     * 根据设备ID查询设备的绑定状态
     *
     * @param equipmentId
     * @return
     */
    Integer findBandStatusByEquipmentId(@Param("equipmentId") String equipmentId);


    Integer updateIsLast(@Param("id") Integer id, @Param("stationId") String stationId);

    /**
     * 批量解绑设备与监测点的绑定关系
     *
     * @param equipmentBOs
     */
    void updateStationEquipments(@Param("equipmentBOs") List<SysStationEquipment> equipmentBOs);

    /**
     * 批量删除监测点和设备的绑定关系
     * @param stationIds
     */
    void deleteStationEquipmentsByStationId(@Param("stationIds") List<String> stationIds);
}
